<?php


namespace app\admin\model;
use think\Request;
use think\Model;

class Role extends Model
{
    /**
     * 获取列表
     * @throws
     */
    public function getRoles(Request $request){
        $defaultConfig = [
            'query'     => $request->get(), //url额外参数
            'fragment'  => '', //url锚点
            'var_page'  => 'page', //分页变量
        ];
        $field = $request->get('search','');
        $keyword = $request->get('keyword','');
        $where = [];
        if($field && ($keyword || $keyword==='0' || $keyword===0)){
            $where[] = [$field,'like','%'.$keyword.'%'];
        }
        $list =  $this->where($where)->paginate($defaultConfig);
        return $list;
    }

}